﻿Imports Oracle.DataAccess.Client
Public Class cImprimeRecibo
    Private lDsImpRC As New dsConsultaCartera
    Private Sub CargaEncabezado(ByVal TipoDoc As String, ByVal Numero As Integer)
        Using conn As OracleConnection = New OracleConnection(My.Settings.ConnectionString)
            Using cmd As OracleCommand = conn.CreateCommand
                cmd.CommandText = "SELECT * FROM CAR_VRECIBOCAJA WHERE IDDOCUMENTO=:PIDDOCUMENTO AND NUMERO=:PNUMERO"
                cmd.Parameters.Add("PIDDOCUMENTO", OracleDbType.Varchar2).Value = TipoDoc
                cmd.Parameters.Add("PNUMERO", OracleDbType.Int32).Value = Numero
                Try
                    conn.Open()
                    lDsImpRC.CAR_VRECIBOCAJA.Load(cmd.ExecuteReader)
                    conn.Close()
                Catch ex As Exception
                    Throw ex
                End Try
            End Using
        End Using
    End Sub
    Private Sub CargaDetalleFacturas(ByVal TipoDoc As String, ByVal Numero As Integer)
        Using conn As OracleConnection = New OracleConnection(My.Settings.ConnectionString)
            Using cmd As OracleCommand = conn.CreateCommand
                cmd.CommandText = "SELECT * FROM CAR_VDETALLEPAGOFACTURA WHERE IDDOCUMENTO=:PIDDOCUMENTO AND NUMERO=:PNUMERO"
                cmd.Parameters.Add("PIDDOCUMENTO", OracleDbType.Varchar2).Value = TipoDoc
                cmd.Parameters.Add("PNUMERO", OracleDbType.Int32).Value = Numero
                Try
                    conn.Open()
                    lDsImpRC.CAR_VDETALLEPAGOFACTURA.Load(cmd.ExecuteReader)
                    conn.Close()
                Catch ex As Exception
                    Throw ex
                End Try
            End Using
        End Using
    End Sub
    Private Sub CargaDetallePlanes(ByVal TipoDoc As String, ByVal Numero As Integer)
        Using conn As OracleConnection = New OracleConnection(My.Settings.ConnectionString)
            Using cmd As OracleCommand = conn.CreateCommand
                cmd.CommandText = "SELECT * FROM CAR_VDETALLEPAGOPLANES WHERE IDDOCUMENTO=:PIDDOCUMENTO AND NUMERO=:PNUMERO"
                cmd.Parameters.Add("PIDDOCUMENTO", OracleDbType.Varchar2).Value = TipoDoc
                cmd.Parameters.Add("PNUMERO", OracleDbType.Int32).Value = Numero
                Try
                    conn.Open()
                    lDsImpRC.CAR_VDETALLEPAGOPLANES.Load(cmd.ExecuteReader)
                    conn.Close()
                Catch ex As Exception
                    Throw ex
                End Try
            End Using
        End Using
    End Sub
    Public Sub New(ByVal TipoDoc As String, ByVal NumeroDoc As Integer, ByVal TipoRc As Int16)
        Try
            lDsImpRC = New dsConsultaCartera
            CargaEncabezado(TipoDoc, NumeroDoc)
            If TipoRc = 1 Then
                CargaDetalleFacturas(TipoDoc, NumeroDoc)
            Else
                CargaDetallePlanes(TipoDoc, NumeroDoc)
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Public ReadOnly Property DatosRecibo() As dsConsultaCartera
        Get
            Return lDsImpRC
        End Get
    End Property
End Class
